import { Pipe, PipeTransform } from '@angular/core';

/**
 * 加价券状态 1：审核通过[已发布] 2：进行中[已发布] 3：已结束 4：已停止 5：草稿
 */
export const makeupCouponStatusArrs: any = [
  { value: 1, label: '已发布', color: '#67C23A' },
  { value: 2, label: '已发布', color: '#67C23A' },
  { value: 3, label: '已结束', color: '#F56C6C' },
  { value: 4, label: '已停止', color: '#F56C6C' },
  { value: 5, label: '草稿', color: '#909399' }
];
@Pipe({
  name: 'makeupCouponStatus'
})
export class MakeupCouponStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    if (value || value === 0) {
      let tempObj = makeupCouponStatusArrs.find((item: any) => {
        return item.value === value;
      })

      switch (type) {
        case 'label':
          return tempObj ? tempObj.label : '-';
        case 'color':
          return tempObj ? tempObj.color : '#333333';
      }
    } else {
      return '-';
    }
  }
}

/**
 * 用户优惠券 状态
 * ----------------------------------------------------------------
 */
export const userCouponStatusArr = [
  {value: 1, label: '待使用', color: '#909399'},
  // {value: 2, label: '售后中', color: '#909399'},
  {value: 3, label: '已过期', color: '#909399'},
  {value: 4, label: '已使用', color: '#909399'},
  {value: 5, label: '强制停止', color: '#909399'}
];
@Pipe({
  name: 'userCouponStatus'
})
export class UserCouponStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = userCouponStatusArr.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj[type] || '-';
    } else {
      return tempObj[type] || '#909399';
    }
  }
}

/**
 * 加价促销 List Status
 * 1、未开始 2、进行中 3、已结束 4、已停止 5 草稿 6、待审核 7、审核不通过
 */
export const makeupDescentArrs = [
  {value: 1, label: '未开始', color: '#008000'},
  {value: 2, label: '进行中', color: '#FF9900'},
  {value: 3, label: '已结束', color: '#888888'},
  {value: 4, label: '已停止', color: '#888888'},
  {value: 5, label: '草稿', color: '#888888'},
  {value: 6, label: '待审核', color: '#888888'},
  {value: 7, label: '审核不通过', color: '#888888'}
];
@Pipe({
  name: 'makeupDescentListStatus'
})
export class MakeupDescentListStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = makeupDescentArrs.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj[type] || '-';
    } else {
      return tempObj[type] || '#909399';
    }
  }
}

/**
 * 用户中奖信息 0.待发放 1.已发放 2.已失效
 */
export const winPrizeStatusArrs = [
  {value: 0, label: '待发放', color: '#FF9900'},
  {value: 1, label: '已发放', color: '#67C23A'},
  {value: 2, label: '已失效', color: '#888888'}
];
@Pipe({
  name: 'winPrizeStatus'
})
export class WinPrizeStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObj: any = winPrizeStatusArrs.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj?.label || '-';
    } else {
      return tempObj?.color || '#909399';
    }
  }
}